package com.powernode.proxy.client;

import com.powernode.proxy.service.OrderService;
import com.powernode.proxy.service.OrderServiceImpl;
import com.powernode.proxy.service.TimerInvocationHandler;
import com.powernode.proxy.util.ProxyUtil;

import java.lang.reflect.Proxy;

public class Client {
    public static void main(String[] args) {
        //创建目标对象
        OrderService target=new OrderServiceImpl();
        //创建代理对象
        /*
        1.newProxyInstance 翻译为：新建代理对象
         */
        /*OrderService proxyObj = (OrderService)Proxy.newProxyInstance(target.getClass().getClassLoader(),
                target.getClass().getInterfaces(),new TimerInvocationHandler(target));*/
        OrderService proxyObj =(OrderService) ProxyUtil.newProxyInstance(target);

        //调用代理对象的代理方法
        proxyObj.generate();
        proxyObj.modify();
        proxyObj.detail();
        String name=proxyObj.getName();
        System.out.println(name);
    }
}
